package com.fenghongzhang.day014;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

public class MyRecycle extends RecyclerView {

    private boolean isFull = false;
    public MyRecycle(@NonNull Context context) {
        super(context);
    }

    public MyRecycle(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }


    @Override //100
    protected void onMeasure(int widthSpec, int heightSpec) {
        super.onMeasure(widthSpec, heightSpec);

//        int mode = MeasureSpec.getMode(100);
//        int size = MeasureSpec.getSize(100);
//        MeasureSpec.EXACTLY;//
//        MeasureSpec.AT_MOST;//

        //默认高,展开高
        if(isFull){
            int i = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
            super.onMeasure(widthSpec, i);
        }else{
            setMeasuredDimension(widthSpec,400);
        }

    }

    public boolean isFull() {
        return isFull;
    }

    public void setFull(boolean full) {
        isFull = full;
        requestLayout();
    }
}
